package filetest;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Test05 {
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个目录名");
        String name = scanner.next();
        File file = new File(name);
        while (true){
            if (file.exists()){
                System.out.println("文件已存在,请重新输入");
                name = scanner.next();
                file = new File(name);
            }else {
                file.createNewFile();
                System.out.println("创建成功");
                break;
            }

        }




    }
}
